package com.djy.shxt.nemt.service;

import com.djy.shxt.nemt.dsl.DSpecialityPost;
import com.djy.shxt.nemt.enity.SpecialityPost;
import com.djy.shxt.nemt.mapper.ISpecialityPost;
import com.gitee.hengboy.mybatis.enhance.dsl.factory.EnhanceDslFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class SpecialityPostService {
    @Autowired
    ISpecialityPost iSpecialityPost;
    @Autowired
    private EnhanceDslFactory dslFactory;

    public Long countAll() {
        return iSpecialityPost.countAll();
    }

    public List<SpecialityPost> selectBySchool(String school) {
        DSpecialityPost dSpecialityPost = DSpecialityPost.DSL();

        return dslFactory.createSearchable()
                .selectFrom(dSpecialityPost)
                .where(dSpecialityPost.school.like("", school, "%"))
                .resultType(SpecialityPost.class)
                .fetch();
    }
}
